@ECHO OFF

:SETUP
SETLOCAL EnableDelayedExpansion
SET CD=%~d0
SET TB=%CD%\ATK\Bin
SET IL=%CD%\ATK\Tools
SET CP=%CD%\ATK\ControlPanels
SET OS=%CD%\ATK\OnlineScanners
REM User Agent string for web requests
SET UA=Mozilla/4.0 (compatible; MSIE 6.1; Windows XP)
REM Limit Rate to [k]ilobytes or [m]egabytes per second
SET LR=1.5m
SET Google Code project URL for this script and resources
SET GC=http://atk.googlecode.com/svn/bin
REM WGET ORIGINAL SOURCE:  "http://users.ugent.be/~bpuype/cgi-bin/fetch.pl?dl=wget/wget.exe
REM TIMER ORIGINAL SOURCE: "http://www.gammadyne.com/timer.exe
REM Skip Slow (SL) always updated downloads YES|NO]
SET SL=NO
IF /I "%1"   EQU "NOSKIP" SET SL=NO
IF /I "%1"   EQU "SKIP"   SET SL=YES
IF /I "%SL%" EQU "YES"    SET SLMSG=Skipping Long/Slow Downloads

ECHO.
ECHO [ATK] Administrator's Tool Kit 7.0
REM 5678901234567890123456789012345678901234567890123456789012345678901234567890
ECHO ===========================================================================
ECHO.
IF /I "%SL%" EQU "YES" ECHO *** NOTICE: %SLMSG%.
GOTO :CHECK_PREREQ

:QUEUE
CALL :TIMER START

REM GOTO :SKIP_TEST

REM  CALL FUNCTION TASK DESCRIPTION                        FILE/TYPE DOWNLOAD DOMAIN     SAVED FILE LOCATION                          DOWNLOAD URL
REM  ============= ======================================= ========= =================== ============================================ ========================

ECHO Downloading/validating core tools from ATK Google Project Hosting:
CALL :TIMER START
CALL :DL_STANDARD  "Wget"                                  ".exe"                        "%TB%"                                       "%GC%/wget.exe"
REM  :DL_STANDARD  "cURL"                                  ".exe"                        "%TB%"                                       "%GC%/curl.exe"
CALL :DL_STANDARD  "Timer"                                 ".exe"                        "%TB%"                                       "%GC%/timer.exe"
CALL :DL_STANDARD  "7Zip"                                  ".exe"                        "%TB%"                                       "%GC%/7za.exe"
CALL :DL_STANDARD  "cygwin.dll API"                        ".dll"                        "%TB%"                                       "%GC%/cygwin1.dll"
CALL :DL_STANDARD  "NDT Client"                            ".exe"                        "%TB%"                                       "%GC%/web100clt.exe"
CALL :TIMER STOP

ECHO Downloading/validating Bleeping Computer tools:
CALL :TIMER START
CALL :DL_STANDARD  "ComboFix"                              ".exe"                        "%IL%\BleepingComputer\combofix\"            "http://www.bleepingcomputer.com/download/combofix/dl/12/"
CALL :DL_STANDARD  "FixExec"                               ".exe"                        "%IL%\BleepingComputer\fixexec\"             "http://www.bleepingcomputer.com/download/fixexec/dl/15/"
CALL :DL_STANDARD  "FixExec (x64)"                         ".exe"                        "%IL%\BleepingComputer\fixexec\x64\"         "http://www.bleepingcomputer.com/download/fixexec/dl/16/"
CALL :DL_STANDARD  "FixNCR"                                ".reg"                        "%IL%\BleepingComputer\FixNCR\"              "http://download.bleepingcomputer.com/reg/FixNCR.reg"
CALL :DL_STANDARD  "GetServices"                           ".zip"                        "%IL%\BleepingComputer\getservices\"         "http://www.bleepingcomputer.com/download/getservices/dl/140/"
CALL :DL_STANDARD  "HostPermsFix"                          ".bat"                        "%IL%\BleepingComputer\hosts-permbat\"       "http://www.bleepingcomputer.com/download/hosts-permbat/dl/87/"
CALL :DL_STANDARD  "RKill"                                 ".exe"                        "%IL%\BleepingComputer\rkill\"               "http://www.bleepingcomputer.com/download/rkill/dl/10/"
CALL :DL_STANDARD  "Shortcut Cleaner"                      ".exe"                        "%IL%\BleepingComputer\shortcut-cleaner\"    "http://www.bleepingcomputer.com/download/shortcut-cleaner/dl/172/"
CALL :DL_STANDARD  "UnHide"                                ".exe"                        "%IL%\BleepingComputer\unhide\"              "http://www.bleepingcomputer.com/download/unhide/dl/6/"
CALL :TIMER STOP

IF /I "%SL%" EQU "YES" GOTO :SKIP_LONG_1

ECHO Downloading/validating Bleeping Computer recommended tools:
CALL :TIMER START
CALL :DL_STANDARD  "AdwCleaner"                            ".exe"                        "%IL%\BleepingComputer\AdwCleaner\"          "http://www.bleepingcomputer.com/download/adwcleaner/dl/125/"
CALL :DL_STANDARD  "Emsisoft Emergency Kit"                ".zip"                        "%IL%\BleepingComputer\EmsisoftEK\"          "http://www.bleepingcomputer.com/download/emsisoft-emergency-kit/dl/102/"
CALL :DL_STANDARD  "Registry Backup"                       ".zip"                        "%IL%\BleepingComputer\RegistryBackup\"      "http://www.bleepingcomputer.com/download/registry-backup-portable/dl/182/"
CALL :DL_STANDARD  "Windows Repair (All-In-One)"           ".zip"                        "%IL%\BleepingComputer\WindowsRepairAIO\"    "http://www.bleepingcomputer.com/download/windows-repair-all-in-one-portable/dl/188/"
CALL :TIMER STOP

:SKIP_LONG_1

ECHO Downloading/validating ESET tools:
CALL :TIMER START
CALL :DL_STANDARD  "NOD32 Antivirus"                       ".msi"                        "%IL%\ESET\NOD32\"                           "http://download.eset.com/eval/win/eav/eav_nt32_enu.msi"
CALL :DL_STANDARD  "NOD32 Antivirus (x64)"                 ".msi"                        "%IL%\ESET\NOD32\x64\"                       "http://download.eset.com/eval/win/eav/eav_nt64_enu.msi"
CALL :DL_STANDARD  "Online Scanner"                        ".exe"                        "%IL%\ESET\OnlineScanner\"                   "http://download.eset.com/special/eos/esetsmartinstaller_enu.exe"
CALL :DL_STANDARD  "SysInspector"                          ".exe"                        "%IL%\ESET\SysInspector\"                    "http://download.eset.com/download/sysinspector/32/ENU/SysInspector.exe"
CALL :DL_STANDARD  "SysInspector (x64)"                    ".exe"                        "%IL%\ESET\SysInspector\x64\"                "http://download.eset.com/download/sysinspector/64/ENU/SysInspector.exe"
CALL :TIMER STOP


ECHO Downloading/validating Kaspersky tools:
CALL :TIMER START
CALL :DL_STANDARD  "Kaspersky TDSSKILLER"                  ".exe"                        "%IL%\Kaspersky\TDSSKILLER\"                 "http://support.kaspersky.com/downloads/utils/tdsskiller.exe"

IF /I "%SL%" EQU "YES" GOTO :SKIP_LONG_2

CALL :DL_FROMLIST  "Kaspersky Virus Removal Tool 9"        ".exe"                        "%IL%\Kaspersky\VRT\VRT9\"                   "http://devbuilds.kaspersky-labs.com/devbuilds/AVPTool/avptool9"
CALL :DL_FROMLIST  "Kaspersky Virus Removal Tool 11"       ".exe"                        "%IL%\Kaspersky\VRT\VRT11\"                  "http://devbuilds.kaspersky-labs.com/devbuilds/AVPTool/avptool11"

:SKIP_LONG_2

CALL :TIMER STOP

ECHO Downloading/validating Malwarebytes tools:
CALL :TIMER START
CALL :DL_STANDARD  "Anti-Malware"                          ".exe"                        "%IL%\Malwarebytes\Anti-Malware\"            "http://www.malwarebytes.org/mbam/program/mbam-setup.exe"
CALL :DL_STANDARD  "Anti-Rootkit"                          ".zip"                        "%IL%\Malwarebytes\Anti-Rootkit\"            "http://downloads.malwarebytes.org/file/mbar"
CALL :DL_STANDARD  "StartupLite"                           ".exe"                        "%IL%\Malwarebytes\StartupLite\"             "http://downloads.malwarebytes.org/file/startuplite"
CALL :DL_STANDARD  "FileASSASSIN"                          ".exe"                        "%IL%\Malwarebytes\FileASSASSIN\"            "http://downloads.malwarebytes.org/file/fileassassin"
CALL :DL_STANDARD  "RegASSASSIN"                           ".exe"                        "%IL%\Malwarebytes\RegASSASSIN\"             "http://downloads.malwarebytes.org/file/regassassin"
CALL :DL_STANDARD  "Chameleon"                             ".zip"                        "%IL%\Malwarebytes\Chameleon\"               "http://downloads.malwarebytes.org/file/chameleon"
CALL :TIMER STOP

ECHO Downloading/validating Microsoft tools:
CALL :TIMER START
CALL :DL_STANDARD  "FixIt DisableAutorun"                  ".msi"                        "%IL%\Microsoft\FixIt\DisableAutorun\"       "http://download.microsoft.com/download/4/F/2/4F2AA3A1-66FC-4F08-86F6-490E9075B751/MicrosoftFixit50471.msi"
CALL :DL_STANDARD  "FixIt DisableIPv6"                     ".msi"                        "%IL%\Microsoft\FixIt\DisableIPv6\"          "http://download.microsoft.com/download/9/E/6/9E6713A9-0433-4BB4-9994-2036C607DE0A/MicrosoftFixit50409.msi"
CALL :DL_STANDARD  "FixIt EnableAutorun"                   ".msi"                        "%IL%\Microsoft\FixIt\EnableAutorun\"        "http://download.microsoft.com/download/8/7/E/87E4C16D-424A-4313-A535-7182E1319886/MicrosoftFixit50475.msi"
CALL :DL_STANDARD  "FixIt EnableIPv6"                      ".msi"                        "%IL%\Microsoft\FixIt\EnableIPv6\"           "http://download.microsoft.com/download/2/E/C/2ECDDF2F-D8EE-42DC-9B1B-6E1A4A293910/MicrosoftFixit50440.msi"
CALL :DL_STANDARD  "FixIt FixItPortable"                   ".exe"                        "%IL%\Microsoft\FixIt\FixItPortable\"        "http://download.microsoft.com/download/E/2/3/E237A32D-E0A9-4863-B864-9E820C1C6F9A/MicrosoftFixit-portable.exe"
CALL :DL_STANDARD  "FixIt PreferIPv4overIPv6"              ".msi"                        "%IL%\Microsoft\FixIt\PreferIPv4overIPv6\"   "http://download.microsoft.com/download/A/7/2/A72E31CC-65C7-4A00-A989-AFA9252E86C9/MicrosoftFixit50410.msi"
CALL :DL_STANDARD  "FixIt PreferIPv6overIPv4"              ".msi"                        "%IL%\Microsoft\FixIt\PreferIPv6overIPv4\"   "http://download.microsoft.com/download/E/A/3/EA3C0AE2-5E07-497D-BF8A-500793B447AA/MicrosoftFixit50441.msi"
CALL :DL_STANDARD  "FixIt ResetHostsFile"                  ".msi"                        "%IL%\Microsoft\FixIt\ResetHostsFile\"       "http://download.microsoft.com/download/9/8/E/98E41ACF-6AE6-40A4-AAB0-73C21998B7B6/MicrosoftFixit50267.msi"
CALL :DL_STANDARD  "FixIt ResetIeSettings"                 ".msi"                        "%IL%\Microsoft\FixIt\ResetIeSettings\"      "http://download.microsoft.com/download/3/1/7/317254BC-6C9D-4532-827A-827041404428/MicrosoftFixit50195.msi"
CALL :DL_STANDARD  "FixIt ResetTCPIP"                      ".msi"                        "%IL%\Microsoft\FixIt\ResetTCPIP\"           "http://download.microsoft.com/download/F/5/0/F5036E5B-A675-441F-AED9-57F9E1E9470F/MicrosoftFixit50199.msi"
CALL :DL_STANDARD  "FixIt ResetWinsock"                    ".msi"                        "%IL%\Microsoft\FixIt\ResetWinsock\"         "http://download.microsoft.com/download/1/A/A/1AA62750-2BE9-44A9-B550-8F5590BB67B8/MicrosoftFixit50203.msi"
CALL :DL_STANDARD  "SysInternals Suite"                    ".zip"                        "%IL%\Microsoft\"                            "http://download.sysinternals.com/files/SysinternalsSuite.zip"
CALL :DL_STANDARD  "SysInternals Autoruns"                 ".exe"                        "%IL%\Microsoft\SysInternals\"               "http://live.sysinternals.com/autoruns.exe"
CALL :DL_STANDARD  "SysInternals Disk2vhd"                 ".exe"                        "%IL%\Microsoft\SysInternals\"               "http://live.sysinternals.com/disk2vhd.exe"
CALL :DL_STANDARD  "SysInternals Diskmon"                  ".exe"                        "%IL%\Microsoft\SysInternals\"               "http://live.sysinternals.com/diskmon.exe"
CALL :DL_STANDARD  "SysInternals PageDefrag"               ".exe"                        "%IL%\Microsoft\SysInternals\"               "http://live.sysinternals.com/pagedfrg.exe"
CALL :DL_STANDARD  "SysInternals Portmon"                  ".exe"                        "%IL%\Microsoft\SysInternals\"               "http://live.sysinternals.com/portmon.exe"
CALL :DL_STANDARD  "SysInternals Process Explorer"         ".exe"                        "%IL%\Microsoft\SysInternals\"               "http://live.sysinternals.com/procexp.exe"
CALL :DL_STANDARD  "Windows XP SP2 Support Tools"          ".exe"                        "%IL%\Microsoft\"                            "http://download.microsoft.com/download/d/3/8/d38066aa-4e37-4ae8-bce3-a4ce662b2024/WindowsXP-KB838079-SupportTools-ENU.exe"
CALL :TIMER STOP

ECHO Downloading/validating DNS Filtering tools:
CALL :TIMER START
CALL :DL_STANDARD  "MVPS Hosts File"                       ".txt"                        "%IL%\MVPS\hosts\"                           "http://winhelp2002.mvps.org/hosts.txt"
CALL :TIMER STOP

:SKIP_TEST

ECHO Downloading/validating Ninite Antimalware Installers:
CALL :TIMER START
CALL :DL_SPECIFIC  "Ad-Aware"                              "adaware.exe"                 "%IL%\Ninites\Antimalware\"                  "http://ninite.com/adaware/ninite.exe"
CALL :DL_SPECIFIC  "Malwarebytes Antimalware"              "malwarebytes.exe"            "%IL%\Ninites\Antimalware\"                  "http://ninite.com/malwarebytes/ninite.exe"
CALL :DL_SPECIFIC  "Spybot Seach and Destroy"              "spybot.exe"                  "%IL%\Ninites\Antimalware\"                  "http://ninite.com/spybot/ninite.exe"
CALL :DL_SPECIFIC  "SUPERAntiSpyware"                      "super.exe"                   "%IL%\Ninites\Antimalware\"                  "http://ninite.com/super/ninite.exe"
CALL :DL_SPECIFIC  "Avast and Malwarebytes"                "avast-malwarebytes.exe"      "%IL%\Ninites\Antimalware\"                  "http://ninite.com/avast-malwarebytes/ninite.exe"
CALL :DL_SPECIFIC  "AVG and Malwarebytes"                  "avg-malwarebytes.exe"        "%IL%\Ninites\Antimalware\"                  "http://ninite.com/avg-malwarebytes/ninite.exe"
CALL :DL_SPECIFIC  "Microsoft Essentials and Malwarebytes" "essentials-malwarebytes.exe" "%IL%\Ninites\Antimalware\"                  "http://ninite.com/essentials-malwarebytes/ninite.exe"
CALL :TIMER STOP

REM GOTO :FINISHED

ECHO Downloading/validating WSUS Offline Update:
CALL :TIMER START
CALL :DL_FROMFILE  "WSUS Offline Update"                   ".zip"                        "%IL%\WSUSOffline\"                          "http://download.wsusoffline.net/StaticDownloadLink-recent.txt"
CALL :TIMER STOP

ECHO Downloading/validating Secunia tools:
CALL :TIMER START
CALL :DL_STANDARD  "Personal Software Inspector"           ".exe"                        "%IL%\Secunia\PSI\"                          "http://secunia.com/PSISetup.exe"
CALL :TIMER STOP

ECHO Downloading/validating misc. system cleaners:
CALL :TIMER START
CALL :DL_STANDARD  "PC Decrapifier"                        ".exe"                        "%IL%\PCDecrapifier\"                        "http://www.pcdecrapifier.com/download"
CALL :DL_STANDARD  "Piriform CCleaner Portable"            "CCleaner.zip"                "%IL%\Piriform\CCleaner\"                    "http://www.piriform.com/ccleaner/download/portable/downloadfile"
CALL :DL_STANDARD  "Piriform CCleaner Extention"           ".ini"                        "%IL%\Piriform\CCleaner\"                    "http://www.winapp2.com/Winapp2.ini"
CALL :TIMER STOP

IF /I "%SL%" EQU "YES" GOTO :SKIP_LONG_3

ECHO Downloading/validating antivirus removal tools:
CALL :TIMER START
CALL :DL_STANDARD  "Avast removal tool"                    ".exe"                        "%IL%\AVremovers\Avast\"                     "http://files.avast.com/files/eng/aswclear.exe"
CALL :DL_STANDDOM  "AVG removal tool"                      ".exe"    "download.avg.com"  "%IL%\AVremovers\AVG\"                       "http://www.avg.com/us-en/utilities"
CALL :DL_STANDARD  "BitDefender removal tool"              ".exe"                        "%IL%\AVremovers\BitDefender\"               "http://www.bitdefender.com/files/KnowledgeBase/file/BitDefender_Uninstall_Tool.exe"
CALL :DL_STANDARD  "ESET removal tool"                     ".exe"                        "%IL%\AVremovers\ESET\"                      "http://www.nod32.nl/download/tool/nod32removal.exe"
CALL :DL_STANDARD  "F-Secure removal tool"                 ".exe"                        "%IL%\AVremovers\F-Secure\"                   "ftp://ftp.f-secure.com/support/tools/uitool/UninstallationTool.zip"
CALL :DL_STANDARD  "Kaspersky removal tool"                ".exe"                        "%IL%\AVremovers\Kaspersky\"                 "http://www.kaspersky.com/downloads/utils/kavremover.exe"
CALL :DL_STANDARD  "Malwarebytes removal tool"             ".exe"                        "%IL%\AVremovers\Malwarebytes\"              "http://www.malwarebytes.org/mbam-clean.exe"
CALL :DL_STANDARD  "McAfee removal tool"                   ".exe"                        "%IL%\AVremovers\McAfee\"                    "http://download.mcafee.com/products/licensed/cust_support_patches/MCPR.exe"
CALL :DL_STANDARD  "Microsoft OneCare removal tool"        ".exe"                        "%IL%\AVremovers\Microsoft\"                 "http://download.microsoft.com/download/4/c/b/4cb845e7-1076-437b-852a-7842a8ab13c8/OneCareCleanUp.exe"
CALL :DL_STANDARD  "Panda removal tool"                    ".exe"                        "%IL%\AVremovers\Panda\"                     "http://www.pandasecurity.com/resources/sop/UNINSTALLER_08.exe"
CALL :DL_STANDARD  "Symantec removal tool"                 ".exe"                        "%IL%\AVremovers\Symantec\"                   "ftp://ftp.symantec.com/public/english_us_canada/removal_tools/Norton_Removal_Tool.exe"
CALL :DL_STANDARD  "Trend Micro removal tool"              ".exe"                        "%IL%\AVremovers\TrendMicro\"                "http://solutionfile.trendmicro.com/solutionfile/EN-1037161/32bit.exe"
CALL :DL_STANDARD  "Trend Micro removal tool (x64)"        ".exe"                        "%IL%\AVremovers\TrendMicro\x64\"            "http://solutionfile.trendmicro.com/solutionfile/EN-1037161/64bit.exe"
CALL :DL_STANDARD  "Webroot removal tool"                  ".exe"                        "%IL%\AVremovers\WebRoot\"                   "http://download.webroot.com/CleanWDF.exe"
CALL :TIMER STOP

:SKIP_LONG_3

CALL :TIMER START
ECHO Creating Windows Namespace Virtual Control Panels..
CALL :MAKE_FOLDER  "Master Control Panel"                  "%CP%\Master Control Panel.{ED7BA470-8E54-465E-825C-99712043E01C}"
CALL :TIMER STOP

GOTO :SKIP_NEW2

CALL :TIMER START
ECHO Creating Online Scanner links..
CALL :DL_STANDARD  "Bitdefender Online Scanner"            ".exe"    "Bitdefender Online Scanner" "http://www.bitdefender.com/scanner/online/"
CALL :DL_STANDARD  "Dr. Web Online Scanner"                ".exe"    "Dr. Web Online Scanner"     "http://vms.drweb.com/online/"
CALL :DL_STANDARD  "ESET Online Scanner"                   ".exe"    "ESET Online Scanner"        "http://www.eset.com/us/online-scanner/"
CALL :DL_STANDARD  "F-Secure Online Scanner"               ".exe"    "F-Secure Online Scanner"    "http://www.f-secure.com/en/web/home_global/online-scanner/"
CALL :DL_STANDARD  "Kaspersky Security Scan"               ".exe"    "Kaspersky Security Scan"    "http://www.kaspersky.com/virus-scanner/"
CALL :DL_STANDARD  "McAfee Security Scan Plus"             ".exe"    "McAfee Security Scan Plus"  "http://home.mcafee.com/downloads/free-virus-scan/"
CALL :DL_STANDARD  "Microsoft Safety Scanner"              ".exe"    "Microsoft Safety Scanner"   "http://www.microsoft.com/security/scanner/"
CALL :DL_STANDARD  "Panda Cloud Antivirus"                 ".exe"    "Panda Cloud Antivirus"      "http://www.cloudantivirus.com/"
CALL :DL_STANDARD  "Symantec Security Check"               ".exe"    "Symantec Security Check"    "http://security.symantec.com/sscv6/home.asp"
CALL :DL_STANDARD  "Trend Micro HouseCall"                 ".exe"    "Trend Micro HouseCall"      "http://housecall.trendmicro.com/"
CALL :TIMER STOP

:SKIP_NEW2

:FINISHED
CALL :TIMER STOP TOTAL
REM Delete any empty directories in saved tools folder hierarchy.
FOR /F "delims=" %%I IN ('DIR %IL% /S /B /AD ^| SORT /R') DO RD "%%I">NUL 2>&1
IF EXIST   %TB%\wget-temp.exe   DEL %TB%\wget-temp.exe>NUL 2>&1
IF EXIST   %TB%\timer.txt       DEL %TB%\timer.txt>NUL 2>&1
IF EXIST %TEMP%\timer.txt     DEL %TEMP%\timer.txt>NUL 2>&1
ECHO   Core tools     : %TB%
ECHO   3rd-Party Tools: %IL%
ECHO   Control Panels : %CP%
GOTO :END

:DL_BASICTMP
START /WAIT /MIN %TB%\wget-temp.exe --no-check-certificate --user-agent="%UA%" --read-timeout=30 --tries=3 --directory-prefix=%~1 %~2
CALL :DL_STATUS %ERRORLEVEL%
GOTO :EOF

:DL_STANDARD
CALL :MAKE_FOLDER "" "%~3"
ECHO  * %~1..
START /MIN /WAIT %TB%\wget-temp.exe --no-check-certificate --user-agent="%UA%" --recursive --level=1 --span-hosts --read-timeout=30 --tries=3 --no-directories --timestamping --no-parent --execute robots=off --no-check-certificate --continue --limit-rate=%LR% --accept=%~2               --directory-prefix=%~3 %~4
CALL :DL_STATUS %ERRORLEVEL%
GOTO :EOF

:DL_STANDDOM
CALL :MAKE_FOLDER "" "%~3"
ECHO  * %~1..
START /MIN /WAIT %TB%\wget-temp.exe --no-check-certificate --user-agent="%UA%" --recursive --level=1 --span-hosts --read-timeout=30 --tries=3 --no-directories --timestamping --no-parent --execute robots=off --no-check-certificate --continue --limit-rate=%LR% --accept=%~2 --domains=%~3 --directory-prefix=%~4 %~5
CALL :DL_STATUS %ERRORLEVEL%
GOTO :EOF

:DL_SPECIFIC
CALL :MAKE_FOLDER "" "%~3"
ECHO  * %~1..
START /MIN /WAIT %TB%\wget-temp.exe --no-check-certificate --user-agent="%UA%" --recursive --level=1 --span-hosts --read-timeout=30 --tries=3 --no-directories --timestamping --no-parent --execute robots=off --no-check-certificate --continue --limit-rate=%LR%                            --output-document=%~3\%~2 %~4
CALL :DL_STATUS %ERRORLEVEL%
GOTO :EOF

:DL_FROMFILE
GOTO :EOF

:DL_FROMLIST
SET INDEX=
IF EXIST %TEMP%\index*.* DEL %TEMP%\index*.*
CALL :DL_BASICTMP %TEMP% %~4
FINDSTR setup %TEMP%\index.html>%TEMP%\index1.txt
FOR /F "tokens=3 delims=><" %%I IN (%TEMP%\index1.txt) DO ECHO %%I>%TEMP%\index2.txt
FOR /F "tokens=1" %%I IN (%TEMP%\index2.txt)           DO CALL :DL_STANDARD "%~1" "%~2" "%~3" "%~4/%%I"
FOR /F %%I IN ('DIR "%~3\*.*" /B /O:D')                DO SET INDEX=%%I
FOR /F %%I IN ('DIR "%~3\*.*" /B /O:D')                DO IF "%~3\%%I" NEQ "%~3\%INDEX%" DEL /Q %~3\%%I
GOTO :EOF

:DL_STATUS
IF "%1" NEQ "0" ECHO  *** WARNING: Download/validation was not successful. 
GOTO:EOF

:MAKE_FOLDER
IF "%~1" NEQ "" (
    ECHO  * Creating %~1..
)
IF NOT EXIST "%~2" (
    MKDIR "%~2">NUL 2>&1
)
GOTO :EOF

:EXTRACTZIP
REM START /MIN /WAIT %TB%\7za.exe e -o%IL%\%1\ -y 
REM CALL :XXXXXXXXXX %1 %2
REM GOTO :EOF

:TIMER
IF EXIST %TB%\timer.exe (
    IF /I "%1" EQU "START" (
        %TB%\timer.exe /q
    )
    IF /I "%1" EQU "STOP" (
        FOR /F "tokens=*" %%I IN ('%TB%\timer.exe /q /s') DO SET TIMER=%%I
        IF "!TIMER!" EQU "The file was not found." (
            SET TIMER=?
            CALL :TIMER START
        )
        IF /I "%2" NEQ "TOTAL" (
            ECHO  t: !TIMER!
			ECHO.
        ) ELSE (
            ECHO Total Duration: !TIMER!
			ECHO.
        )
    )
)
GOTO :EOF

:CHECK_PREREQ
IF NOT EXIST %TB%\. MD %TB%
IF NOT EXIST %IL%\. MD %IL%
IF NOT EXIST %TB%\wget.exe (
    IF NOT EXIST .\wget.exe (
        GOTO :PREREQ_MISSING
    )
)
IF EXIST        .\wget.exe (
    MOVE /Y     .\wget.exe %TB%\wget.exe>NUL 2>&1
)
IF EXIST     %TB%\wget.exe (
    COPY /Y  %TB%\wget.exe %TB%\wget-temp.exe>NUL 2>&1
)
IF EXIST     %TB%\wget-temp.exe GOTO :QUEUE

:PREREQ_MISSING
ECHO ERROR: WGET.EXE is missing.
ECHO.
ECHO WGET is essential for aquiring all other files required by this script.
ECHO The latest Win32 port of WGET can be downloaded from here:
ECHO.
ECHO    %WG%
ECHO.
ECHO You must download and save WGET.EXE into the same directory as this script,
ECHO and try again. Please re-run this script when WGET.EXE has finished
ECHO downloading, and has been saved or copied into this directory.
GOTO :END

:END
ENDLOCAL
REM 5678901234567890123456789012345678901234567890123456789012345678901234567890
REM This script is free to USE and MODIFY, or REDISTRIBUTE in its' ORIGINAL FORM;
REM as long as this REM'd passage is always included.
ECHO.
ECHO.===========================================================================
ECHO Copyright 2013, Micheal Espinola Jr (micheal@espinola.net)
ECHO.

:EOF
